<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/pages/common.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>员工信息</title>

<script type="text/javascript">
$(function () {

    //1.初始化Table
    var oTable = new TableInit();
    oTable.Init();

    //2.初始化Button的点击事件
    var oButtonInit = new ButtonInit();
    oButtonInit.Init();
	//初始化提示框的位置：top-center，bottom-left，bottom-right
    toastr.options.positionClass = 'toast-top-center';
	
    $('#exampleModal').on('hide.bs.modal',function(){
    	$("#fm")[0].reset();
    	$('#fm').data('bootstrapValidator').resetForm(true);
    });
    
    $('#passwords').change(function () {
    	$("#passwords2").val("");
    });
    
    $('#stremark1').change(function () {
    	if (document.getElementById('stremark1').value!='车间操作员' && document.getElementById('stremark1').value!='库管') {
    		$('#stremark2').selectpicker('val',(''));
    		document.getElementById("stremark2").disabled=true;
    	}else{
    		$('#stremark2').selectpicker('val',('白班'));
    		document.getElementById("stremark2").disabled=false;
    	}
    }); 
  	//jQuery，既阻止默认行为又停止冒泡
    $("#ss").on('click',function(){
    	    return false;//当然 也阻止了事件本身
    });

});


var TableInit = function () {
    var oTableInit = new Object();
    //初始化Table
    oTableInit.Init = function () {
        $('#tb_departments').bootstrapTable({
            url: '${pageContext.request.contextPath }/staff/list.do',         //请求后台的URL（*）
            //showExport: true, //是否显示导出
            method: 'get',                      //请求方式（*）
            toolbar: '#toolbar',                //工具按钮用哪个容器
            striped: true,                      //是否显示行间隔色
            cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: true,                   //是否显示分页（*）
            sortable: false,                     //是否启用排序
            sortOrder: "asc",                   //排序方式
            queryParams: oTableInit.queryParams,//传递参数（*）
            sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
            pageNumber:1,                       //初始化加载第一页，默认第一页
            pageSize: 10,                       //每页的记录行数（*）
            pageList : [10,20,30],       //可供选择的每页的行数（*）
            //search: true,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
            strictSearch: true,
            //showColumns: true,                  //是否显示所有的列
            //showRefresh: true,                  //是否显示刷新按钮
            minimumCountColumns: 2,             //最少允许的列数
            clickToSelect: true,                //是否启用点击选中行
            height: 500,                        //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "staffid",                     //每一行的唯一标识，一般为主键列
            //showToggle:true,                    //是否显示详细视图和列表视图的切换按钮
            //cardView: false,                    //是否显示详细视图
            detailView: false,                   //是否显示父子表
            columns: [{
                checkbox: true
            }, {
                field: 'staffid',
                title: '员工id',
                visible: false
            }, {
                field: 'staffnumbering',
                title: '员工编号'
            }, {
                field: 'staffname',
                title: '员工姓名'
           /*  }, {
                field: 'passwords',
                title: '密码' */
            }, {
                field: 'sex',
                title: '性别'
            }, {
                field: 'phone',
                title: '电话'
         /*    }, {
                field: 'factoryid',
                title: '工厂' */
            }, {
                field: 'department.departmentname',
                title: '部门'
            }, {
                field: 'stremark1',
                title: '职位'
            }, {
                field: 'stremark2',
                title: '班组'
            }, {
                field: 'duty',
                title: '职责'
            }, {
                field: 'role.rname',
                title: '角色'
            }, {
                field: 'rsdate',
                title: '入社日期'
            }, {
                field: 'stenter',
                title: '录入人'
            }, {
                field: 'stentertime',
                title: '录入时间'
            }]
        });
    };

    //得到查询的参数
    oTableInit.queryParams = function (params) {
        var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            limit: params.limit,   //页面大小
            offset: params.offset,  //页码
            staffname:$.trim($('#staffnameTJ').val()), 
    		sex:$.trim($('#sexTJ').val()),  
        };
        return temp;
    };
    return oTableInit;
};


var ButtonInit = function () {
    var oInit = new Object();
    var postdata = {};

    oInit.Init = function () {
        //初始化页面上面的按钮事件
    };

    return oInit;
};


function refresh(){
	setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
		var row=$('#tb_departments').bootstrapTable('getData');
		if(row.length == 0){
			window.location.reload();
		}
	},1000);
}

function doDelete() {
	var row=$.map($("#tb_departments").bootstrapTable('getSelections'),function(row){
		return row ;
	});
	if (row.length == 0) {
		toastr.warning('请至少选择一条数据!');
	}else{
		var ids="";
		var names="";
		for(var i=0;i<row.length;i++){
			if(i==0 || i=="0"){
				ids+=row[i].staffid;
				names+=row[i].staffname;
			}else{
				ids+=","+row[i].staffid;
				names+=","+row[i].staffname;
			}
		}
		
		//询问框
		Ewin.confirm({ message: "确认要删除选择的数据吗？" }).on(function (e) {
	       if (!e) {
	         return;
	       } 
	    	var url = "${pageContext.request.contextPath }/staff/delete.do";
		    $.post(url, "ids="+ids, function(data) {
				if (data == 1) {
					toastr.success('删除成功');
					setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
						$('#tb_departments').bootstrapTable('refresh');
						refresh()
					},1000);
				} else if (data == 2) {
					toastr.warning('该信息已删除!');
					setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
						$('#tb_departments').bootstrapTable('refresh'); 
						refresh()
					},1000); 
				} else {
					toastr.error('删除失败');
					setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
						$('#tb_departments').bootstrapTable('refresh');
						refresh()
					},1000);
				}
			}); 
	    }); 
	}
}

function doAdd() {
	
	$("#bt").html("新增员工信息(密码默认为123)");
	$("#staffid").val("");
 	$("#passwords").val("123");
	$("#passwords2").val("123"); 
	$('#stremark2').selectpicker('val',(''));
	var SelectArr = $("select")
  	for (var i = 0; i < SelectArr.length; i++) {
  		SelectArr[i].options[0].selected = true; 
  	}
	document.getElementById("stremark2").disabled=true;
	$('#exampleModal').modal(open);
	//清空表单
	//document.getElementById("fm").reset();
}

function doView() {
	//取表格的选中行数据
    var row = $("#tb_departments").bootstrapTable('getSelections');
	if (row.length == 1) {
		$("#bt").html("修改员工信息");
		$("#staffid").val(row[0].staffid);
		$("#staffnumbering").val(row[0].staffnumbering);
		$("#staffname").val(row[0].staffname);
		$('#sex').selectpicker('val',(row[0].sex));
		$("#phone").val(row[0].phone);
		$('#factoryid').selectpicker('val',(row[0].factoryid));
		$('#departmentid').selectpicker('val',(row[0].departmentid));
		$("#departmentid").val(row[0].departmentid);
		$("#duty").val(row[0].duty);
		$("#rsdate").val(row[0].rsdate);
		$('#stremark1').selectpicker('val',(row[0].stremark1));
		if (row[0].stremark2=='') {
    		document.getElementById("stremark2").disabled=true;
    		$('#stremark2').selectpicker('val',(''));
    	}else{
    		document.getElementById("stremark2").disabled=false; 
    		$('#stremark2').selectpicker('val',(row[0].stremark2));
    	} 
		$('#stremark3').selectpicker('val',(row[0].stremark3));
		$('#exampleModal').modal(open);
	}else{
		toastr.warning('请选择一条数据!');
	}
}
function save() {
    var bootstrapValidator = $("#fm").data('bootstrapValidator');  
    //开启验证
    bootstrapValidator.validate();  
    if (bootstrapValidator.isValid()){
    	if (document.getElementById('staffid').value=='') {
    		if (document.getElementById('passwords').value=='') {
    			$("#passwords").val("123");
    		}
			var url = "${pageContext.request.contextPath }/staff/add.do";
			var title="新增";
    	} else {
			var url = "${pageContext.request.contextPath }/staff/update.do";
			var title="修改";
    	}  
	    $.post(url, $("#fm").serialize(), function(data) {
			if (data == 1) {
				toastr.success(title+'成功');
				setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
					if (document.getElementById('staffid').value=='') {
						$('#exampleModal').modal('hide');
						$('#tb_departments').bootstrapTable('refresh');  
						refresh();
					}else{
						window.location.reload();
					}
				},1000);
			} else if (data == -1) {
				toastr.warning('该编号已存在，不能重复新增');
			} else if (data == 2) {
				toastr.warning('该数据已删除');
				setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
					$('#exampleModal').modal('hide');
					$('#tb_departments').bootstrapTable('refresh'); 
					refresh()
				},1000);
			} else {
				toastr.error(title+'失败');
			}
		});
    }else{
	    return;  
    } 
}
function seach() {
	$('#tb_departments').bootstrapTable('refresh'); 
}
</script>
</head>
<body>
	<div class="panel-body" style="padding-bottom:0px;">
        <div class="panel panel-default">
            <div class="panel-heading">查询条件</div>
            <div class="panel-body">
                <form id="formSearch" class="form-horizontal">
                    <div class="form-group" style="margin-top:15px">
                        <label class="control-label col-sm-1" for="txt_search_departmentname">员工姓名 </label>
                        <div class="col-sm-3">
                            <input type="text" class="form-control" id="staffnameTJ">
                        </div>
                        <label class="control-label col-sm-1" for="txt_search_statu">性别</label>
                        <div class="col-sm-3">
                            <!-- <input type="text" class="form-control" id="sexTJ"> -->
                            <select id="sexTJ" class="form-control selectpicker" >
								<option value="">请选择性别</option>
								<option>男</option>
								<option>女</option>
							</select>
                        </div>
                        <div class="col-sm-4" style="text-align:left;">
                            <button type="button" style="margin-left:50px" id="btn_query" class="btn btn-primary" onclick="seach()">查询</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>       

		


        <div id="toolbar" class="btn-group">
            <button id="btn_add" type="button" class="btn btn-default" onclick="doAdd()">
                <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
            </button>
            <button id="btn_edit" type="button" class="btn btn-default" onclick="doView()">
           		 <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>修改
            </button>
            <button id="btn_delete" type="button" class="btn btn-default" onclick="doDelete()">
                <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除
            </button>
            <button id="btn_add" type="button" class="btn btn-default" onclick="douploadModal()">
                <span class="glyphicon glyphicon-bullhorn" aria-hidden="true"></span>导入
            </button>
            <!--  <button id="btn_delete" type="button" class="btn btn-default" onclick="doExport()">
                <span class="glyphicon glyphicon-export" aria-hidden="true"></span>导出当前页
            </button> -->
            <button id="btn_delete" type="button" class="btn btn-default" onclick="doExportall()">
                <span class="glyphicon glyphicon-export" aria-hidden="true"></span>导出所有
            </button>
            
            
            <script type="text/javascript">
	        	function doExportFile() {
	        		Ewin.confirm({message : "确认要导出数据模板吗？"}).on(
    					function(e) {
   						if (!e) {return;}
						window.location.href="${pageContext.request.contextPath}/staff/doExportFile.do"; 
					})
				}
	        	function doExport() {
	        		Ewin.confirm({message : "确认要导出所有数据吗？"}).on(
    					function(e) {
   						if (!e) {return;}
						window.location.href="${pageContext.request.contextPath}/staff/doExport.do"; 
					})
				}
	        	function doExportall() {
	        		Ewin.confirm({message : "确认要导出所有数据吗？"}).on(
    					function(e) {
   						if (!e) {return;}
						window.location.href="${pageContext.request.contextPath}/staff/doExportall.do"; 
					})
				}
	        	
	        	function douploadModal() {
	        		$('#uploadModal').modal(open);
	        		//清空表单
	        		document.getElementById("importForm").reset();
	        	}
	        	
	        	function uploadBtn() {
	        		 var fileName = $("#fileInput").val();
	        		 if (fileName.length > 0) {
	        		     var formData = new FormData($("#importForm")[0]);  
	        		     $.ajax({  
	        		          url: '${pageContext.request.contextPath}/staff/uplodeFile.do' ,  
	        		          type: 'post',  
	        		          data: formData,
	        		          async: false,  
	        		          cache: false,  
	        		          contentType: false,  
	        		          processData: false,  
	        		          success: function (data) { 
	        		        	  if (data == 1) {
	        		        		  toastr.success("文件导入成功！");
	        		        		  setTimeout(function() {//使用setTimeout()方法设定定时2000毫秒
	        		        		    $('#uploadModal').modal('hide'); 
	        		        		   $('#tb_departments').bootstrapTable('refresh'); 
	        						  },1000);
	        		        	  }else if(data == -1){
	        		        		  toastr.warning("导入的数据不符合导入条件（员工编号不能重复，找不到对应的部门）！");  
	        		        	  }else{
	        		        		  toastr.warning("文件格式异常，文件导入失败！");  
	        		        	  }
	        		          },  
	        		          error: function (data) {
	        		        	  toastr.error("文件格式异常，文件导入失败！");  
	        		          }  
	        		     }); 
	        		 }else{
	        			 toastr.warning("上传文件为空，请选择要导入的文件！");  
	        		}
	        	}
	        	
            </script>
        </div>
        <table id="tb_departments"></table>
    </div>
    
    <div class="modal fade" id="uploadModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
   		<div class="modal-dialog" role="document">
    		<div class="modal-content">
      			<div class="modal-header">
        			<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        			<h4 class="modal-title" id="exampleModalLabel">
        				<span style="font-size:13px">excel导入</span>
        			</h4>
      			</div>
      			<div class="modal-body">
	        		<form id="importForm" class="form-horizontal">
	          			<div class="form-group">
							<label  class="col-sm-3 control-label"></label>
							<div class="col-sm-7"> 
		           				 <button id="btn_delete" type="button" class="btn btn-default" onclick="doExportFile()">
					                <span class="glyphicon glyphicon-export" aria-hidden="true"></span>导出
					            </button>
	          				 </div>
	          			</div>
	          			<div class="form-group">
				            <label class="col-sm-5 control-label">excel文件:</label>
				            <div class="col-sm-5"> 
					            <input id="fileInput" name="file" type="file" accept=".xls,.xlsx"/>
	          				</div>
	          			</div>
	        			<div class="form-group"> 
				   			<div class="col-sm-3 col-sm-offset-7">  
						        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						        <button type="submit"  name="submit"  class="btn btn-primary" id="ss" onclick="uploadBtn()">导入</button>
			      			</div>
			      		</div>
	        		</form>
	      		</div>
    		</div>
  		</div>
	</div>
    
    
      <div class="modal fade bs-example-modal-lg" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
   		<div class="modal-dialog  modal-lg" role="document">
    		<div class="modal-content">
      			<div class="modal-header">
        			<button type="button" class="close closefm" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        			<h4 class="modal-title" id="exampleModalLabel">
        				<span id="bt" style="font-size:13px"></span>
        			</h4>
      			</div>
      			<div class="modal-body">
	        		<form id="fm" class="form-horizontal" style="margin-right: 5%;">
	          			<div class="form-group">
	           				 <label class="col-sm-2 control-label">员工编号:</label>
	            			 <div class="col-sm-4"> 
		            			 <input type="text" class="form-control" id="staffnumbering" name="staffnumbering" autocomplete="off">
		            			 <input type="hidden" id="staffid" name="staffid" >
		            			 <span class="xing"></span>
	          				</div>
				            <label class="col-sm-2 control-label">员工姓名:</label>
				            <div class="col-sm-4"> 
					            <input type="text" class="form-control" id="staffname" name="staffname">
					            <span class="xing"></span>
	          				</div>
	          			</div>
	          			
	          			<div class="form-group">
							<label class="col-sm-2 control-label">密码:</label>
							<div class="col-sm-4"> 
								<input type="password" name="passwords" id="passwords" class="col-xs-12 col-sm-4 form-control"/>
	          				</div>
							<label class="col-sm-2 control-label">再次输入密码:</label>
							<div class="col-sm-4"> 
								<input type="password" name="passwords2" id="passwords2" class="col-xs-12 col-sm-4 form-control" />
							</div>
						</div>
   			
	          			<div class="form-group">
				            <label  class="col-sm-2 control-label">性别:</label>
				          	<div class="col-sm-4"> 
				          		<select id="sex" name="sex" class="form-control selectpicker" >
									<option>男</option>
									<option>女</option>
								</select>
								<span class="xing"></span>
	          				 </div>
				            <label  class="col-sm-2 control-label">电话:</label>
							<div class="col-sm-4"> 
								<input type="text" class="form-control" id="phone" name="phone" autocomplete="off">
								<span class="xing"></span>
	          				 </div>
	          			</div>
	          			<%-- <div class="form-group">
				            <label  class="col-sm-2 control-label">工厂:</label>
							<div class="col-sm-8"> 
								<select id="factoryid" name="factoryid" class="form-control selectpicker" >
									<c:if test="${staff.factoryid != null && staff.factoryid != ''}">
						         		<option value="${staff.factoryid}">${staff.factory.fname}</option>
				       				</c:if>
				       				<c:if test="${staff.factoryid == null || staff.factoryid == ''}">
				       					<option value="0">请选择工厂</option>
				       				</c:if>
								</select>
								<script type="text/javascript">
					                $(function(){
					                    $.ajax({
							                type: "post",
							                url: "${pageContext.request.contextPath }/factory/all.do",
							                dataType: 'JSON',
							                async: false,
							                success: function (data) {
							                      //设置下拉列表中的值的属性
							                      for ( var i = 0; i < data.length; i++) {
							                    	  	if (data[i].prid != $.trim($('#factoryid').val())) {
									                        //增加下拉列表。
									                        $("#factoryid").append("<option value='"+data[i].fid+"'>"+data[i].fname+"</option>");
														}
												 }
							                    //必须执行，否则数据新增失败
							                     $('#factoryid').selectpicker('refresh'); 
							                     //$('#prukuid').selectpicker('render'); 
							                }
							            });
					                });
					                $('#factoryid').change(function () {
					                	$("#factoryid option[value='0']").remove(); //删除Select中Value='3'的Option 
					                	$('#factoryid').selectpicker('refresh'); 
					                    //$('#factoryid').selectpicker('render'); 
					                });
					            	//思路如上。你可以将点击时将文本框中值传到后台，后台返回数据后，在将数据存入下拉列表对象中。
					        	</script>
	          				 </div>
	          			</div> --%>
	          			<div class="form-group">
	          				<label  class="col-sm-2 control-label">入社日期:</label>
							<div class="col-sm-4"> 
								<input type="text" id="rsdate" name="rsdate" readonly class="form_datetime form-control">
	          				 </div>
				            <label  class="col-sm-2 control-label">部门:</label>
							<div class="col-sm-4"> 
								<select id="departmentid" name="departmentid" class="form-control selectpicker" >
					        	</select>
					        	<span class="xing"></span>
					        	<script type="text/javascript">
					                $(function(){
					                    $.ajax({
							                type: "post",
							                url: "${pageContext.request.contextPath }/department/all.do",
							                dataType: 'JSON',
							                async: false,
							                success: function (data) {
							                      //设置下拉列表中的值的属性
							                      for ( var i = 0; i < data.length; i++) {
							                    	  	if (data[i].prid != $.trim($('#departmentid').val())) {
									                        //增加下拉列表。
									                        $("#departmentid").append("<option value='"+data[i].departmentid+"'>"+data[i].departmentname+"</option>");
														}
												 }
							                    //必须执行，否则数据新增失败
							                     $('#departmentid').selectpicker('refresh'); 
							                     //$('#departmentid').selectpicker('render'); 
							                }
							            });
					                });
					                /* $('#departmentid').change(function () {
					                	$("#departmentid option[value='0']").remove(); //删除Select中Value='3'的Option 
					                	$('#departmentid').selectpicker('refresh'); 
					                    //$('#departmentid').selectpicker('render'); 
					                }); */
					            	//思路如上。你可以将点击时将文本框中值传到后台，后台返回数据后，在将数据存入下拉列表对象中。
					        	</script>
	          				 </div>
	          			</div>
	          			<div class="form-group">
				            <label  class="col-sm-2 control-label">职位:</label>
							<div class="col-sm-4"> 
								<select id="stremark1" name="stremark1" class="form-control selectpicker" >
									<option>总经理</option>
									<option>副总经理</option>
									<option>经理</option>
									<option>厂长</option>
									<option>主管</option>
									<option>库管</option>
									<option>车间操作员</option>
									<option>员工</option>
								</select>
								<span class="xing"></span>
	          				 </div>
				            <label  class="col-sm-2 control-label">班组:</label>
							<div class="col-sm-4"> 
								<select id="stremark2" name="stremark2" class="form-control selectpicker" >
									<option>白班</option>
									<option>晚班</option>
								</select>
	          				 </div>
	          			</div>
	          			
	          			<div class="form-group">
				            <label  class="col-sm-2 control-label">职责:</label>
							<div class="col-sm-4"> 
								<input type="text" class="form-control" id="duty" name="duty" autocomplete="off">
	          				 </div>
	          				 <label  class="col-sm-2 control-label">角色:</label>
							<div class="col-sm-4"> 
								<select id="stremark3" name="stremark3" class="form-control selectpicker" >
					        	</select>
					        	<span class="xing"></span>
					        	<script type="text/javascript">
					                $(function(){
					                    $.ajax({
							                type: "post",
							                url: "${pageContext.request.contextPath }/Role/queryAllByMution.do",
							                dataType: 'JSON',
							                async: false,
							                success: function (data) {
							                      //设置下拉列表中的值的属性
							                      for ( var i = 0; i < data.length; i++) {
							                    	  	if (data[i].rid != $.trim($('#stremark3').val())) {
									                        //增加下拉列表。
									                        $("#stremark3").append("<option value='"+data[i].rid+"'>"+data[i].rname+"</option>");
														}
												 }
							                    //必须执行，否则数据新增失败
							                     $('#departmentid').selectpicker('refresh'); 
							                     //$('#departmentid').selectpicker('render'); 
							                }
							            });
					                });
					                $('#departmentid').change(function () {
					                	$("#departmentid option[value='0']").remove(); //删除Select中Value='3'的Option 
					                	$('#departmentid').selectpicker('refresh'); 
					                    //$('#departmentid').selectpicker('render'); 
					                });
					            	//思路如上。你可以将点击时将文本框中值传到后台，后台返回数据后，在将数据存入下拉列表对象中。
					        	</script>
	          				 </div>
	          			</div>
	          			
	        			<div class="modal-footer"> 
				   			<div class="col-sm-3 col-sm-offset-10"> 
						        <button type="button" class="btn btn-default closefm" data-dismiss="modal" >关闭</button>
						        <button type="submit"  name="submit"  class="btn btn-primary" onclick="save()">保存</button>
			      			</div>
			      		</div>
	        		</form>
	      		</div>
    		</div>
  		</div>
	</div>
	
		<!-- 时间控件 -->
	<script type="text/javascript">
	    $(".form_datetime").datetimepicker({
			/* 显示格式 */       
	    	format: "yyyy-mm-dd",
	/*     	format: "yyyy-mm-dd hh:ii:ss", */
	        /* 完成关闭 */
	        autoclose: true,
	       /*  今天 时间按钮*/
	        todayBtn: true, 
	       /*  今天的时间变黄色 */
	        todayHighlight:true, 
	        /* 定位 */
	        pickerPosition: "bottom-left",
	        /* 最小值 */
	        /* startDate: "2013-02-14 10:00", */
	        minuteStep: 10,
	        /*  语言 */
	        language: 'zh-CN',  
			/* 分上午下午 */
	        showMeridian: true,
	        /* 分的所有 */
	        minuteStep:true,
	        clearBtn:true,// 自定义属性,true 显示 清空按钮 false 隐藏 默认:true
	        startView: 2,//月视图
			minView: 2//日期时间选择器所能够提供的最精确的时间选择视图
	    }).on('hide',function(e) {  
	        //e.preventDefault();		//e.preventDefault()阻止事件默认行为。
	    	e.stopPropagation(); //e.stopPropagation()阻止事件冒泡
	    	$('#fm').data('bootstrapValidator')  
            .updateStatus('rsdate', 'NOT_VALIDATED',null)  
            .validateField('rsdate');  
    	});
	</script>
	<script type="text/javascript">
	$(function() {
		var layerTips = parent.layer === undefined ? layui.layer : parent.layer
		$("#fm").bootstrapValidator({
			feedbackIcons : {
				valid : 'glyphicon glyphicon-ok',
				invalid : 'glyphicon glyphicon-remove',
				validating : 'glyphicon glyphicon-refresh'
			},
			fields : {
				staffnumbering : {
					validators : {
						notEmpty : {
							message : '员工编号不能为空'
						},
					}
				},
				staffname : {
					validators : {
						notEmpty : {
							message : '员工姓名不能为空'
						},
					}
				},
				passwords : {
					validators : {
						/* notEmpty : {
							message : '密码不能为空'
						}, */
					}
				}, 
				
				passwords2 : {
					validators : {
						/* notEmpty : {
							message : '密码不能为空'
						}, */ 
						identical: {
							field: 'passwords',
							message: '与密码不等，请重新确认密码'
						},  
					}
				},
				sex : {
					validators : {
						notEmpty : {
							message : '性别不能为空'
						},
					}
				},
				phone : {
					validators : {
						notEmpty : {
							message : '联系电话不能为空'
						},
						stringLength: {
	                         min: 11,
	                         max: 11,
	                         message: '请输入联系电话号码'
	                     }, 
	                     regexp: {
	                         regexp:    /^(0?(13[0-9]|15[012356789]|17[013678]|18[0-9]|14[57])[0-9]{8})|(400|800)([0-9\\-]{7,10})|(([0-9]{4}|[0-9]{3})(-| )?)?([0-9]{7,8})((-| |转)*([0-9]{1,4}))?$/,
	                         message: '请输入正确的联系电话号码'
	                     }
					}
				},
				factoryid : {
					validators : {
						notEmpty : {
							message : '工厂不能为空'
						},
						regexp: {
	                         regexp:  /^[1-9]\d*$/,
	                         message: '请选择工厂'
	                     }
					}
				},
				departmentid : {
					validators : {
						notEmpty : {
							message : '部门不能为空'
						},
						regexp: {
	                         regexp:  /^[1-9]\d*$/,
	                         message: '请选择部门'
	                     }
					}
				},
				stremark3 : {
					validators : {
						notEmpty : {
							message : '角色不能为空'
						},
						regexp: {
	                         regexp:  /^[1-9]\d*$/,
	                         message: '请选择角色'
	                     }
					}
				},
				/* duty : {
					validators : {
						notEmpty : {
							message : '职责不能为空'
						},
					}
				}, */
				/* rsdate : {
					validators : {
						notEmpty : {
							message : '入社日期不能为空'
						},
					}
				}, */ 
				stremark1 : {
					validators : {
						notEmpty : {
							message : '请选择职位'
						},
					}
				}, 
				/* stremark2 : {
					validators : {
						notEmpty : {
							message : '请选择班组'
						},
					}
				},  */
				
			},
		});
	});
	</script>
	<!-- <script>
	 $(document).ready(function() {
            $('.registerForm').bootstrapValidator({
                fields: {
                	/* staffname: {
                        message: 'The username is not valid',
                        validators: {
                            notEmpty: {
                                message: '不为空'
                            },
                            stringLength: {
                                min: 6,
                                max: 30,
                                message: '6-30位'
                            },
                            regexp: {
                                regexp: /^[a-zA-Z0-9_]+$/,
                                message: '只能由字母、数字和下划线组成'
                            }
                        }
                    }, */
                    staffnumbering : {
                    	message: 'The username is not valid',
    					validators : {
    						notEmpty : {
    							message : '员工编号不能为空'
    						},
    					}
    				},
    				staffname : {
    					validators : {
    						notEmpty : {
    							message : '员工姓名不能为空'
    						},
    					}
    				},
    				sex : {
    					validators : {
    						notEmpty : {
    							message : '员工姓名不能为空'
    						},
    					}
    				},
    				fax : {
    					validators : {
    						notEmpty : {
    							message : '传真不能为空'
    						},
    						/* stringLength: {
    	                         min: 11,
    	                         max: 12,
    	                         message: '请输入传真号码'
    	                     }, */
    	                     regexp: {
    	                         regexp:  /0\d{2,3}-\d{7,8}/,
    	                         message: '请输入正确的传真号码'
    	                     }
    					}
    				},
    				phone : {
    					validators : {
    						notEmpty : {
    							message : '联系电话不能为空'
    						},
    						/* stringLength: {
    	                         min: 11,
    	                         max: 11,
    	                         message: '请输入联系电话号码'
    	                     }, */
    	                     regexp: {
    	                         regexp:    /^(0?(13[0-9]|15[012356789]|17[013678]|18[0-9]|14[57])[0-9]{8})|(400|800)([0-9\\-]{7,10})|(([0-9]{4}|[0-9]{3})(-| )?)?([0-9]{7,8})((-| |转)*([0-9]{1,4}))?$/,
    	                         message: '请输入正确的联系电话号码'
    	                     }
    					}
    				},
    				factoryid : {
    					validators : {
    						notEmpty : {
    							message : '工厂不能为空'
    						},
    					}
    				},
    				departmentid : {
    					validators : {
    						notEmpty : {
    							message : '部门不能为空'
    						},
    					}
    				},
    				duty : {
    					validators : {
    						notEmpty : {
    							message : '职责不能为空'
    						},
    					}
    				},
    				rsdate : {
    					validators : {
    						notEmpty : {
    							message : '入社日期不能为空'
    						},
    						date : {
    							format : "yyyy-MM-dd"
    						}
    					}
    				},
                }
            });
        });
    </script>  -->
</body>
</html>